const Service = require('egg').Service;

class userService extends Service {
  async find_user(phone) {
    const user = await this.app.mysql.get('user',{
        phone
    })
    return user;
  }
  async detail(id){
    return await this.app.mysql.query("select * from product where id=?",[id])
  }
  async created_address(params){
    await this.app.mysql.insert('address',{
      ...params,
      location:JSON.stringify(params.location)
    })
  }
  async select_address(user_id){
    const res=await this.app.mysql.select('address',{
      where:{
        user_id
      }
    })
    return res
  }
  async get_address(id){
   const res= await this.app.mysql.get('address',{
      id
    })
    return {
      ...res,
      location:JSON.parse(res.location)
    }
  }
  
}

module.exports = userService;